package com.yufeng.collaboration.controller;

import com.yufeng.collaboration.entity.DocumentUser;
import com.yufeng.collaboration.service.DocumentUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/documentUsers")
public class DocumentUserController {

    @Autowired
    private DocumentUserService documentUserService;

    @GetMapping("/{documentId}")
    public List<DocumentUser> getDocumentUsersByDocumentId(@PathVariable Integer documentId) {
        return documentUserService.getDocumentUsersByDocumentId(documentId);
    }

    @PostMapping
    public void addDocumentUser(@RequestBody DocumentUser documentUser) {
        documentUserService.addDocumentUser(documentUser);
    }

    @DeleteMapping("/{id}")
    public void deleteDocumentUser(@PathVariable Integer id) {
        documentUserService.deleteDocumentUser(id);
    }
}